<?php

namespace app\admin\service;

use app\admin\dao\AccountBillDao;
use app\admin\dao\ConsultingServerDao;

/**
 * Class OptionsService
 * @package app\admin\service
 */
class OptionsService
{
    // dao
    private AccountBillDao $accountBillDao;

    public function __construct(AccountBillDao $accountBillDao)
    {
        $this->accountBillDao = $accountBillDao;
    }

    /**
     * 财务列表
     * @return array
     */
    public function financeOptions(): array
    {
        $accountType = [
            ['label' => '余额', 'value' => PAYMENT_ACCOUNT],
            ['label' => '微信支付', 'value' => PAYMENT_WXPAY],
            ['label' => '抖音支付', 'value' => PAYMENT_TTPAY],
            ['label' => '获客卡', 'value' => PAYMENT_CARD],
            ['label' => '通信币', 'value' => PAYMENT_COIN],
            ['label' => '保证金', 'value' => PAYMENT_MARGIN],
            ['label' => '对公转账', 'value' => PAYMENT_OFFLINE],
        ];

        $billType0 = [
            ['label' => '提现', 'value' => TRADE_CASH],
            ['label' => '余额充值', 'value' => TRADE_BALANCE_RECHARGE],
            ['label' => '获客卡&余额充值', 'value' => TRADE_TOKEN_RECHARGE],
            ['label' => '付费服务', 'value' => TRADE_CONSULTING_SERVER],
            ['label' => '悬赏', 'value' => TRADE_REWARD],
            ['label' => '红包', 'value' => TRADE_RED_PACKET],
            ['label' => '案源', 'value' => TRADE_SOURCE],
            ['label' => 'AXB通话', 'value' => TRADE_AXB],
        ];

        $billType1 = [
            ['label' => '提现', 'value' => TRANSFER_CASH],
            ['label' => '余额充值', 'value' => TRANSFER_BALANCE_RECHARGE],
            ['label' => '获客卡充值', 'value' => TRANSFER_CARD_RECHARGE],
            ['label' => '通信币充值', 'value' => TRANSFER_COIN_RECHARGE],
            ['label' => '补贴', 'value' => TRANSFER_SHARE_SUBSIDY],
            ['label' => '律师分成', 'value' => TRANSFER_SHARE_LAWYER],
            ['label' => '邀请人分成', 'value' => TRANSFER_SHARE_INVITER],
            ['label' => '案源分成', 'value' => TRANSFER_SHARE_LAW_CASE],
        ];

        return [
            'accountType' => $accountType,
            'type' => [
                ['label' => '支付', 'value' => 'pay', 'children' => $billType0],
                ['label' => '退款', 'value' => 'refund', 'children' => $billType0],
                ['label' => '转账', 'value' => 'transfer', 'children' => $billType1],
            ],
        ];
    }

    /**
     * 订单列表
     * @return array
     */
    public function orderOptions(): array
    {
        $services = $this->getConsultingServerDao()->selectOptionsOfConsulting();

        return [
            // 付款方式
            'payment' => [
                ['label' => '余额', 'value' => 'account'],
                ['label' => '微信支付', 'value' => 'wxpay'],
            ],
            // 服务
            'serverId' => $services,
            // 订单状态
            'status' => [
                //   1.未付款 2.进行中 3.结算中 4.已完成 5.申请退款 6.已退款 8.已取消
                ['label' => '未付款', 'value' => '1'],
                ['label' => '进行中', 'value' => '2'],
                ['label' => '结算中', 'value' => '3'],
                ['label' => '已完成', 'value' => '4'],
                ['label' => '申请退款', 'value' => '5'],
                ['label' => '已退款', 'value' => '6'],
                ['label' => '已取消', 'value' => '8'],
            ]
        ];
    }

    private function getConsultingServerDao(): ConsultingServerDao
    {
        return app(ConsultingServerDao::class);
    }

}


